package com.ddwl.goods.dao;

import com.ddwl.common.constant.BaseEnum;
import com.ddwl.goods.mapper.ActivityMapper;
import com.ddwl.goods.model.Activity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.time.Instant;

@Repository
public class ActivityDao {
    @Autowired
    private ActivityMapper activityMapper;

    /**
     * 新增活动
     * @param activity
     */
    public void insert(Activity activity){
        activity.setGmtCreated(Instant.now());
        activity.setDFlag(BaseEnum.DflagEnum.NOT_DELETE.getCode());
        activityMapper.insertById(activity);
    }

    /**
     * 跟新活动
     * @param activity
     */
    public void update(Activity activity){
        activity.setGmtModified(Instant.now());
        activityMapper.updateById(activity);
    }

    /**
     * 删除活动
     */
    public void delete(String activityId){
        activityMapper.deleteById(activityId);
    }
}

